1. Field of the Invention
The disclosure relates to a network traversal method and a network communication system using the network traversal method.
2. Description of Related Art
Along with the development of network technologies and infrastructures and the increase of network users, many network address translators (NATs) are adopted to resolve the problem of insufficient network addresses in the Internet Protocol (IP). However, the adoption of NATs brings a great operation obstacle to applications using peer-to-peer transmission, such as P2P file transmission applications and IP phone applications.
To be specific, NATs can be categorized into full cone NATs, restricted cone NATs, port restricted cone NATs, and symmetric NATs. A characteristic of the full cone NATs is that after a connection is established between an internal user and an external user, any external user can communicate with the internal user according to a NAT assigned address/port of the internal user. A characteristic of the restricted cone NATs is that after a connection is established between an internal user and an external user, only the external address connected with the internal user can communicate with the internal user according to a NAT assigned address/port of the internal user. A characteristic of the port restricted cone NATs is that after a connection is established between an internal user and an external user, only the external addresses/ports connected to the internal user can communicate with the internal user according to a NAT assigned address/port of the internal user. A characteristic of the symmetric NATs is that a NAT assigned address/port is assigned to each application sent by an internal user to different destination, and only the address/port of the corresponding destination can communicate with the NAT assigned address/port.
As described above, in an environment in which many users use private IP addresses (or virtual IP addresses), when an external user outside a NAT is about to establish a data transmission connection with an internal user inside the NAT, the request message issued by the external user is blocked by the NAT and accordingly the internal user cannot receive this request message. As a result, the connection cannot be established.
In order to resolve foregoing problem, network protocols such as the simple traversal of user datagram protocol through NAT (STUN), the traversal using relay NAT (TURN), and the interactive connectivity establishment (ICE) are provided. The STUN network protocol specified by Request for Comments (RFC) 3489 provides a technique, wherein an internal user inside a NAT can obtain the addresses/ports assigned by the NAT and the type of the NAT, and can establish a connection with an external user outside the NAT by providing aforementioned information to the external user. However, the STUN network protocol cannot work on a symmetric NAT. According to the TURN network protocol, a TURN server is deployed in a public domain, and the TURN server assigns an address/port to an internal user inside a NAT and records the mapping relationship between an address/port used by the internal user for communicating with external users and the assigned address/port in a mapping table. After that, data entering and leaving the NAT is always relayed by the TURN server so as to traverse the NAT. Even though the TURN network protocol can be applied to traversal of a symmetric NAT, the TURN server may become a bottleneck in the performance of the entire system since the data streams of all internal users of the NAT have to pass through the TURN server. The ICE network protocol provides a NAT traversal method making use of the STUN network protocol and the TURN network protocol. In this NAT traversal method, when a connection is to be established between users by traversing a NAT, the users first collect their own candidate address information and then exchange the candidate address information with each other. After that, each user performs a connection testing by using the other party's candidate address. Finally, the users determine an optimal connection for transmitting data.
Some NAT traversal methods are provided based on the network protocols described above to allow an external user outside a NAT to traverse the NAT and establish a connection with an internal user inside the NAT. For example, in a hole punching method provided by the RFC 5128, a rendezvous server is deployed in a public domain, and every NAT user establishes a control message connection with the rendezvous server. When a user A is about to establish a direct NAT traversal connection with a user B, the user A first sends a connection establishment request message to the rendezvous server. After receiving the connection establishment request message, the rendezvous server sends the NAT assigned address/port of the user B to the user A and the NAT assigned address/port of the user A to the user B. Once the user A receives the address information of the user B, the user A sends a testing packet to the NAT assigned address/port of the user B. Herein the testing packet is blocked by the NAT of the user B, but meanwhile, a NAT mapping table of the user A is updated to allow the NAT assigned address/port of the user B to transfer data to the user A. After that, the user B also sends a testing packet to the NAT assigned address/port of the user A. Herein the NAT mapping table of the user B is updated to allow the NAT assigned address/port of the user A to transmit data to the user B. Accordingly, a bidirectional NAT traversal connection is successfully established. Even though the hole punching method can resolve some problems in NAT traversal, it cannot be applied if both NATs are symmetric NATs or one of them is a port restricted cone NAT and the other one is a symmetric NAT because, as described above, a symmetric NAT assigns different NAT assigned addresses/ports according to different destinations.
A port prediction technique is disclosed in U.S. Pat. No. 7,328,280 in order to achieve NAT traversal when both NATs are symmetric NATs or one of them is a port restricted cone NAT and the other one is a symmetric NAT. Because a symmetric NAT assigns ports to its internal users at certain intervals, in the port prediction method, the user that is about to establish a connection first tests the port assignation rule of the corresponding NAT and obtain the port assignation rule of the other party through information exchange. After that, the users respectively send a plurality of testing packets to the port predicted according to the other party's port assignation rule. Theoretically, a NAT traversal connection is established through the procedure described above. However, in the present technique, a lot of prediction messages and communication time are spent for predicting the ports assigned by the NATs, and the prediction success rate cannot be ensured.